﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
using Telerik.Windows.Controls.Data.DataFilter;
using Telerik.Windows.Controls;

namespace Kaskelot.SP.UI.Analys.FilterComponents
{
    public class EditorTemplateSelector : DataTemplateSelector
    {
        private List<EditorTemplateRule> editorTemplateRules;
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            ItemPropertyDefinition info = (ItemPropertyDefinition)item;
            foreach (EditorTemplateRule rule in this.EditorTemplateRules)
            {
                if (rule.PropertyName == info.PropertyName)
                {
                    return rule.DataTemplate;
                }
            }

            return base.SelectTemplate(item, container);
        }

        public List<EditorTemplateRule> EditorTemplateRules
        {
            get
            {
                if (this.editorTemplateRules == null)
                {
                    this.editorTemplateRules = new List<EditorTemplateRule>();
                }
                return this.editorTemplateRules;
            }
        }
    }
}
